package de.haw.gka.a1;

public class Knoten implements Comparable<Knoten>{

	public Knoten(String name, int attr){
		this.name = name;
		knotenarttibutt = attr;
		
	}

    public Knoten(String name){
       this.name = name;
    }

public String toString(){
	return  this.name + " | " + this.knotenarttibutt;
}


	


	public int getKnotenarttibutt() {
	return knotenarttibutt;
}
	public void setKnotenarttibutt(int knotenarttibutt) {
		this.knotenarttibutt = knotenarttibutt;
	}
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}

	public boolean equals(Object obj){
		if(obj instanceof Knoten){
			Knoten tmp = (Knoten)obj;
			return ((this.name.equals(tmp.getName())) && (this.knotenarttibutt == tmp.getKnotenarttibutt()));
		}
		return false;
	}
	public double dst (Knoten goal) {		
		final double x_d = goal.knotenarttibutt - knotenarttibutt;	    
		return Math.sqrt(x_d);	    
	}
	
	public double dstHeu (Knoten goal) {		
		double x_d = 0;
		if(this.compareTo(goal) == 0) return 1;
		else if(this.compareTo(goal) == 1) 	x_d = this.knotenarttibutt - goal.knotenarttibutt;	    
		else x_d = goal.knotenarttibutt - this.knotenarttibutt;
		return Math.sqrt(x_d);
	}
	
	public void setfskore(Double fscore){
		this.fskore=fscore;
	}
	public Double getfskore(){
		return fskore;
	}
	public int hashCode(){
		Integer attr = new Integer(knotenarttibutt);
		return name.hashCode() + attr.hashCode();
	}

	
	private int knotenarttibutt;
	private String name;
	private Double fskore=0.0;
	
	@Override
	public int compareTo(Knoten o) {
		if(this.knotenarttibutt > o.getKnotenarttibutt()) return 1;
		else if(this.knotenarttibutt < o.getKnotenarttibutt()) return -1;
		else return 0;
	}

}

